<template>
  <div>
    <carouse :data="jobBannerData||[]"></carouse>
    <div class="job-page">
      <div class="job-page-center">
        <div
          class="job-explain"
          @click="toResume"
          v-if="resumeIntegrity.resumeIntegrity < 100"
        >请完善您的简历，发布求职意向获得高薪Offer</div>
        <div class="job-content">
          <div class="job-content-left">
            <div class="job-box job-list">
              <div class="job-list-top">
                <div class="job-list-top-left">
                  <div>
                    {{data.jobDetailPage.jobName}}
                    <span class="left-money">
                      <span style="color:#999;" v-if="data.jobDetailPage.tax == 0">税前&nbsp;</span>
                      <span style="color:#999;" v-if="data.jobDetailPage.tax == 1">税后&nbsp;</span>
                      {{data.jobDetailPage.salaryPerMonthLow ? data.jobDetailPage.salaryPerMonthLow :'---'}}&nbsp;-
                      {{data.jobDetailPage.salaryPerMonthHigh ? data.jobDetailPage.salaryPerMonthHigh + 'W' :'---'}}
                      <span
                        style="color:#999;font-size:12px;"
                      >/{{data.jobDetailPage.salaryCount ? data.jobDetailPage.salaryCount + '年' : '---'}}</span>
                    </span>
                  </div>
                  <div class="job-list-sub-text">
                    <span>{{data.jobDetailPage.workCity ? data.jobDetailPage.workCity : '---'}}</span>
                    <span>|</span>
                    <span>{{data.jobDetailPage.workTime ? data.jobDetailPage.workTime : '---'}}</span>
                    <span>|</span>
                    <span>{{data.jobDetailPage.eduReq ? data.jobDetailPage.eduReq : '---'}}</span>
                    <span>|</span>
                    <span>{{data.jobDetailPage.jobLicenseReq ? data.jobDetailPage.jobLicenseReq : '---'}}</span>
                    <span>|</span>
                    <span>{{data.jobDetailPage.feedbackTime ? data.jobDetailPage.feedbackTime +'反馈' :'---'}}</span>
                  </div>
                </div>
                <div class="job-list-top-right">
                  <div>{{data.jobDetailPage.companyName}}</div>
                  <div class="job-list-sub-text">
                    <span>{{data.jobDetailPage.companySize ? data.jobDetailPage.companySize : '---'}}</span>
                    <span>|</span>
                    <span>{{data.jobDetailPage.companyNature ? data.jobDetailPage.companyNature : '---'}}</span>
                  </div>
                </div>
              </div>
              <div class="job-list-bottom">
                <div class="job-list-bottom-bonus">
                  自荐奖金：
                  {{data.jobDetailPage.bonus ? data.jobDetailPage.bonus + 'K' : '---'}}
                </div>
                <el-button
                  v-if="data.jobDetailPage.report == 10"
                  class="oneself-button"
                  @click="doSelf(data.jobDetailPage.companyId,data.jobDetailPage.jobId)"
                >自荐</el-button>
                <el-button v-else class="primary-button gary-button" disabled>已自荐</el-button>
              </div>
            </div>
            <div class="job-box job-details">
              <details-list :sta="!sta" title="职位亮点" :data="data.jobDetailPage.jobSpot"></details-list>
              <details-list :sta="sta" title="职位描述" :data="data.jobDetailPage.jobDesc"></details-list>
              <details-list :sta="sta" title="任职要求" :data="data.jobDetailPage.jobReq"></details-list>
              <details-list :sta="sta" title="工作城市" :data="data.jobDetailPage.workCity"></details-list>
            </div>
          </div>
          <div class="job-content-right">
            <job-consultant
              :job-id="data.jobDetailPage.jobId"
              :jrr-id="data.jobDetailPage.jrrId"
              :company-name="data.jobDetailPage.companyName"
              :job-name="data.jobDetailPage.jobName"
              :data="data.jobDetailPage.consultantDto"
            ></job-consultant>

            <div class="job-box job-details-company">
              <div class="company-head">{{data.jobDetailPage.companyName}}</div>
              <div class="company-content">
                <el-row>
                  <img src="../../../assets/img/job/type.png">
                  {{data.jobDetailPage.companyType ? data.jobDetailPage.companyType : '---'}}
                </el-row>
                <el-row>
                  <img src="../../../assets/img/job/size.png">
                  {{data.jobDetailPage.companySize ? data.jobDetailPage.companySize : '---'}}
                </el-row>
                <el-row>
                  <img src="../../../assets/img/job/xingzhi.png">
                  {{data.jobDetailPage.companyNature ? data.jobDetailPage.companyNature : '---'}}
                </el-row>
                <el-row>
                  <img src="../../../assets/img/job/dizhi.png">
                  {{data.jobDetailPage.workCity ? data.jobDetailPage.workCity : '---'}}
                </el-row>
              </div>
            </div>
          </div>
        </div>
      </div>
      <el-dialog style="margin-top: 15vh;" :visible.sync="loginDialog" title="提示">
        <all-dialog
          :job-id="data.jobDetailPage.jobId"
          :jrr-id="data.jobDetailPage.jrrId"
          :company-name="data.jobDetailPage.companyName"
          :job-name="data.jobDetailPage.jobName"
          :platformUserId="platformUserId"
          :type="type"
          v-model="loginDialog"
        ></all-dialog>
      </el-dialog>
    </div>
    <page-footer></page-footer>
  </div>
</template>

<script>
import carouse from '../carouse'
import jobList from '../job-list'
import detailsList from './details-list'
import jobConsultant from '../../../components/job-consultant'
import pageFooter from '../../../components/page-footer'
import allDialog from '../../../components/all-dialog'
import _g from '../../../assets/utils/global'

export default {
  data() {
    return {
      sta: false,
      param: {
        page: 1,
        pageSize: 20,
        orderBy: 'DESC',
        searchName: '',
        workCityTypeId: '',
        companyTypeId: 0,
        companyNatureId: 0,
        companySizeId: 0,
        licenseTypeId: 0,
        releaseTimeId: 0,
        salaryYearStart: '',
        salaryYearEnd: ''
      },
      data: {
        jobDetailPage: {
          consultantDto: {}
        }
      },
      jobBannerData: [],
      params: {
        companyId: 6,
        jobId: 6
      },
      resumeIntegrity: {},
      loginDialog: false,
      type: 0,
      talentInfo: {},
      platformUserId: ''
    }
  },
  methods: {
    getQuery() {
      // console.log(this.$route)
      if (this.$route.query.jobId != '' && this.$route.query.companyId != '') {
        this.params.jobId = this.$route.query.jobId
        this.params.companyId = this.$route.query.companyId
        this.initData()
      }
    },
    initData() {
      this.jobBannerData = JSON.parse(
        localStorage.getItem(localSaved.jobBannerData)
      )
      if (this.jobBannerData == null) {
        this.jobBannerData = []
        _g.apiPost('/talent/initJobListPage.do', this.param).then(res => {
          console.log(res.data)
          res.data.bannerDtoList.forEach(item => {
            this.jobBannerData.push(JSON.parse(item.content))
          })
        })
      }
      _g.apiPost('/talent/JobDetailPage.do', this.params).then(res => {
        console.log(res)
        this.data = res.data
      })
    },
    doSelf(companyId, jobId) {
      if (this.resumeIntegrity.resumeIntegrity < 90) {
        this.loginDialog = true
        this.type = 1
        return
      } else if (
        this.resumeIntegrity.resumeIntegrity == 90 &&
        this.resumeIntegrity.onlineResume != 0
      ) {
        this.loginDialog = true
        this.type = 1
        return
      }

      //3执业信息异常
      if (this.talentInfo.state == 2) {
        this.loginDialog = true
        this.type = 3
        this.platformUserId = this.talentInfo.platformUserId
        return
      }

      //4执业信息待审核
      if (this.talentInfo.state == 0) {
        this.loginDialog = true
        this.type = 4
        this.platformUserId = this.talentInfo.platformUserId
        return
      }

      //0 登录时简历为完善 1自荐时简历未完善 2简历投递中 3执业信息异常 4执业信息待审核
      _g.apiPost('/talent/recommendSelfResume.do', {
        companyId: companyId,
        jobId: jobId
      }).then(res => {
        if (res.status == 0) {
          this.loginDialog = true
          this.type = 2
          this.data.jobDetailPage.report = 11
          this.platformUserId = res.data['platformUserId']
          this.jrrId = res.data['jrrId']
          this.data.jobDetailPage.jrrId = this.jrrId
        }

        _g.toMessage(res)
        this.$emit('on-pitch', true)
      })
    },
    toResume() {
      this.$router.push({ path: '/resume' })
    }
  },
  mounted() {
    this.getQuery()
    this.resumeIntegrity = JSON.parse(localStorage.getItem('resumeIntegrity'))
    this.talentInfo = JSON.parse(localStorage.getItem(localSaved.userInfo))
  },
  components: {
    carouse,
    jobList,
    detailsList,
    jobConsultant,
    pageFooter,
    allDialog
  }
}
</script>

<style lang="scss" scoped>
</style>
